<template>
  <div class="doubleText" :style="{ background: `url(${imgbgc})`, 'background-size': '100% 100%' }">
    <div class="innerBox">
      <div class="content">
        <div class="contInner">
          <div class="title">双人关系测验</div>
          <div class="redioBox">
            <el-radio-group v-model="radioValue" @change="radioFn">
              <el-radio border v-for="(item,index) in radioArr" :key="index" :label="item">{{item}}</el-radio>
              <el-radio border :label="'other'">其他</el-radio>
            </el-radio-group>
            <span v-show="radioValue=='other'" class="otherInputBox">
              <el-input v-model="otherValue"/>
            </span>
          </div>
          <div class="btn">
            <el-button type="primary" @click="nextFn">下一步</el-button>
          </div>
        </div>
      </div>
      <div class="rightBox" v-if="personType=='child'">
        <img src="@/assets/images/c2.png" alt="">
      </div>
      <div class="rightBox" v-else>
        <img src="@/assets/images/p2.jpg" alt="">
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      imgbgc: require('../assets/images/pbgc.jpg'),
      personType: 'adult',
      radioValue: '',
      radioArr: [
        '父亲', '伴侣', '母亲', '孩子', '老师', '同学', '朋友'
      ],
      otherValue: '',
      testType: ''
    }
  },
  methods: {
    radioFn(val) {
      console.log(val,this.radioValue)
    },
    nextFn() {
      if(this.radioValue === '' || (this.radioValue === 'other' && this.otherValue === '')) {
        this.$message.info('请选择测验关系！')
      } else {
        this.$router.push({
          path: '/doubleTextList',
          query: {
            itemname: this.radioValue === 'other' ? this.otherValue : this.radioValue,
            testType: this.testType
          }
        })
      }
    }
  },
  mounted() {
    this.testType = this.$route.query.testType ? this.$route.query.testType : ''
    this.personType = sessionStorage.getItem('personType')
    if(this.personType == 'adult') {
      this.imgbgc = require('../assets/images/pbgc.jpg')
    } else {
      this.imgbgc = require('../assets/images/cbgc.jpg')
    }
  }
}
</script>

<style lang="scss" scoped>
.doubleText {
  height: calc(100vh - 200px);
  background: url(../assets/images/pbgc.jpg);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  padding: 100px 140px;
  .innerBox {
    height: calc(100% - 80px);
    padding: 40px 20px;
    background-color: #ffffff;
    box-shadow: 35px 35px 50px 0px 
      rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
  }
  .content {
    width: 45%;
    // display: flex;
    // padding: 10px 80px 0px 100px;
    padding: 10px 5% 0 2%;
    .contInner {
      height: calc(100% - 50px);
    }
  }
  .rightBox {
    width: 55%;
    padding: 20px;
    // display: flex;
    // padding: 80px 150px 80px 0px;
    img {
      width: 95%;
      height: 100%;
    }
  }
  .title {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 40px;
    color: #009fb5;
  }
  .redioBox {
    margin-bottom: 20px;
    position: relative;
    .otherInputBox {
      position: absolute;
      bottom: 10px;
      left: 300px;
    }
  }
  .btn {
  }
}
</style>

<style lang="scss">
.doubleText {
  .el-input{
    width: 100px;
  }
  .el-radio-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    width: 300px;
    .el-radio {
      width: calc(50% - 10px);
      text-align: left;
      margin: 0 10px 10px 0;
    }
  }
  .el-radio {
    width: 200px;
    margin-bottom: 20px;
  }
  .el-radio.is-bordered.is-checked, .el-radio__inner:hover {
    border-color: #009fb5;
  }
  .el-radio__input.is-indeterminate .el-radio__inner, .el-radio__input.is-checked .el-radio__inner {
    background-color: #009fb5;
    border-color: #009fb5;
  }
  .el-radio__input.is-checked+.el-radio__label {
    color: #009fb5;
  }
}
</style>